//
//  CustomTableViewCell.m
//  APP_login
//
//  Created by edz on 7/8/21.
//  Copyright © 2021 baicai. All rights reserved.
//

#import "CustomTableViewCell.h"
#import "CustomTabCellModel.h"
#import "Masonry.h"

@interface CustomTableViewCell()

@property(nonatomic,strong) UIImageView *imageViewOfCell;
@property(nonatomic,strong) UILabel *nickNameLable;
@property(nonatomic,strong) UILabel *messageLable;
@property(nonatomic,strong) UILabel *timeLable;

@end
@implementation CustomTableViewCell{
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _imageViewOfCell = [[UIImageView alloc] init];
        [self.contentView addSubview: _imageViewOfCell];
        [_imageViewOfCell mas_makeConstraints:^(MASConstraintMaker *make){
            make.top.left.mas_equalTo(10);
            make.width.height.mas_equalTo(55);
        }];
        
        _nickNameLable = [[UILabel alloc] init];
        [self.contentView addSubview:_nickNameLable];
        [_nickNameLable mas_makeConstraints:^(MASConstraintMaker *make){
            make.top.mas_equalTo(10);
            make.left.mas_equalTo(80);
            make.width.mas_equalTo(200);
            make.height.mas_equalTo(30);
        }];
        _nickNameLable.font = [UIFont systemFontOfSize:20];
        
        _messageLable = [[UILabel alloc] init];
        [self.contentView addSubview:_messageLable];
        _messageLable.textColor = [UIColor grayColor];
        [_messageLable mas_makeConstraints:^(MASConstraintMaker *make){
            make.top.mas_equalTo(45);
            make.left.mas_equalTo(80);
            make.width.mas_equalTo(200);
            make.height.mas_equalTo(20);
        }];
        _messageLable.font = [UIFont systemFontOfSize:19];
       
        _timeLable = [[UILabel alloc] init];
        [self.contentView addSubview:_timeLable];
        _timeLable.textColor = [UIColor grayColor];
        [_timeLable mas_makeConstraints:^(MASConstraintMaker *make){
            make.top.mas_equalTo(10);
            make.left.mas_equalTo(320);
            make.width.mas_equalTo(80);
            make.height.mas_equalTo(20);
        }];
        _timeLable.font = [UIFont systemFontOfSize:12];
        _timeLable.textAlignment = NSTextAlignmentRight;
    }
    return self;
}

- (void) setModel:(CustomTabCellModel *)model{
    _model = model;
    _nickNameLable.text = _model.nickName;
    _messageLable.text = _model.message;
    _timeLable.text = _model.time;
    [_imageViewOfCell setImage:[UIImage imageNamed:_model.image]];
}

@end
